﻿using System.Collections.Generic;
using OperationPlugins.Applications.Models;

namespace OperationPlugins.Applications
{
    /// <summary>
    /// The application data context.
    /// </summary>
    public interface IApplicationDataContext
    {
        /// <summary>
        /// Creates a new application installation.
        /// </summary>
        /// <param name="installation">The application installation data.</param>
        /// <returns>The installed application.</returns>
        AppInstance NewAppInstallation(AppInstallation installation);

        /// <summary>
        /// Gets all application installations.
        /// </summary>
        /// <returns>All application installations.</returns>
        IEnumerable<AppInstallation> GetAppInstallations(); 
            
        /// <summary>
        /// Gets the data of application instance by id.
        /// </summary>
        /// <param name="id">id</param>
        /// <returns>The requested application instance of null if not found.</returns>
        AppInstance GetAppInstanceById(string id);

        /// <summary>
        /// Gets the data of application instace by application id.
        /// </summary>
        /// <param name="appId">application id</param>
        /// <returns>The requested application instance of null if not found.</returns>
        AppInstance GetAppInstaceByAppId(string appId);

        /// <summary>
        /// Saves the data of application instance.
        /// </summary>
        /// <param name="appInstance">The data of application instance to save.</param>
        void SaveAppInstance(AppInstance appInstance);

        /// <summary>
        /// Removes the data of application instance.
        /// </summary>
        /// <param name="id">id</param>
        void RemoveAppInstance(string id);

        /// <summary>
        /// Gets the binary data.
        /// </summary>
        /// <param name="binaryDataId">binary data id</param>
        /// <returns>The requested binary data or null if not found.</returns>
        BinaryData GetBinaryDataByBinaryDataId(string binaryDataId);

        /// <summary>
        /// Saves the binary data.
        /// </summary>
        /// <param name="binaryData">The binary data to save.</param>
        void SaveBinaryData(BinaryData binaryData);

        /// <summary>
        /// Removes the binary data.
        /// </summary>
        /// <param name="binaryDataId">binary data id</param>
        void RemoveBinaryData(string binaryDataId);

    }
}
